/*
 * Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
 *
 * Licensed under the Mulan PSL v2.
 * You can use this file according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of the License at
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
 * FOR MORE DETAILS.
 */

#pragma once

#include <set>
#include <vector>

#include "Utility/Algebra/Matrix.h"

#include "DataStructure/Common/Out.h"
#include "DataStructure/Common/Status.h"
#include "DataStructure/Input/Solver/AnaysisTypes.h"

#include "DBManager/Common/DBManagerNamespace.h"
#include "DBManager/Common/DomainRequest.h"
#include "DBManager/DBServiceFactory.h"
#include "DBManager/IService/Result/IResultDomainsService.h"
SG_DBMANAGER_NAMESPACE_OPEN

namespace Post
{

    template <typename T>
    class AddTrait
    {
      public:
        using ServiceDataType = T;
        /**
         * @brief    添加结果数据
         * 根据DomainRequest信息，保存结果数据，
         * 对于静力分析需要传递analysisType、subcase参数
         * @param    domain
         * @param    data
         * @return
         * @author   wxc
         * @date     2024.12.12
         */
        virtual SG::DataStructure::Common::Status Add (DomainRequest domain, std::vector<T>& data) = 0;
        virtual SG::DataStructure::Common::Status AddBySubcaseId (SG::DataStructure::Common::Id subcaseId, std::vector<T>& data) = 0;
        virtual SG::DataStructure::Common::Status AddByDomainId (SG::DataStructure::Common::Id domainid, std::vector<T>& data)   = 0;
    };

    template <typename T>
    class FindByDomainTrait
    {
      public:
        /**
         * @brief    通过DomainRequest, 获取相应的结果数据
         *
         * @param    domain 对于静力分析需要传递analysisType、subcase参数
         * @param [out] entities 返回的结果
         * @return   是否查找成功
         * @author   wxc
         * @date     2024.12.12
         */
        virtual SG::DataStructure::Common::Status Find (DomainRequest domain, _OUT std::vector<T>& entities) = 0;

        virtual SG::DataStructure::Common::Status Find (SG::DataStructure::Common::Id domainid, _OUT std::vector<T>& entities) = 0;

        /**
         * @brief   通过DomainRequest与eIdSet， 获取相应的结果数据
         *
         * @param    domain 对于静力分析需要传递analysisType、subcase参数
         * @param    eIdSet 筛选某domain内的某些元素 eid为elementId
         * @param [out] entities 返回的结果
         * @return   是否查找成功
         * @author   wxc
         * @date     2024.12.12
         */
        virtual SG::DataStructure::Common::Status
        Find (DomainRequest domain, std::set<SG::DataStructure::Common::Id> eIdSet, _OUT std::vector<T>& entities) = 0;
    };

    class SizeTrait
    {
      public:
        /**
         * @brief 获取特定domain的实体总数。
         *
         * 此函数根据提供的domain ID 返回与之关联的实体总数。
         *
         * @param domainId domain的 ID。
         * @return 返回实体的数量。
         */
        virtual std::size_t Size (DomainRequest domain) = 0;
    };

}  // namespace Post
SG_DBMANAGER_NAMESPACE_CLOSE
